package com.huaqin.punan.headset;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by punan on 5/21/13.
 */
public class AppPickerDialog extends Activity {

    private GridView mGridView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.app_picker_dialog);

        mGridView = (GridView)findViewById(R.id.mygridview);

        List<Map<String,Object>> items = new ArrayList<Map<String, Object>>();
        for(int i=0; i<9; i++){
            Map<String,Object>item = new HashMap<String,Object>();
            item.put("imageItem",R.drawable.ic_launcher);
            items.add(item);
        }

        SimpleAdapter adapter = new SimpleAdapter(this,
                items,
                R.layout.grid_item,
                new String[]{"imageItem"},
                new int[]{R.id.image_item});

        mGridView.setAdapter(adapter);

        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(AppPickerDialog.this,"i="+i+"l="+l,Toast.LENGTH_LONG).show();
            }
        });

    }
}